|
In computer science, the Hopcroft–Karp algorithm is an algorithm that takes as input a bipartite graph and produces as output a maximum cardinality matching – a set of as many edges as possible with the property that no two edges share an endpoint. It runs in time in the worst case, where is set of edges in the graph, and is set of vertices of the graph. In the case of dense graphs the time bound becomes , and for random graphs it runs in near-linear time. The algorithm was found by . As in previous methods for matching such as the Hungarian algorithm and the work of , the Hopcroft–Karp algorithm repeatedly increases the size of a partial matching by finding augmenting paths. However, instead of finding just a single augmenting path per iteration, the algorithm finds a maximal set of shortest augmenting paths. As a result, only iterations are needed. The same principle has also been used to develop more complicated algorithms for non-bipartite matching with the same asymptotic running time as the Hopcroft–Karp algorithm. ==Augmenting paths== A vertex that is not the endpoint of an edge in some partial matching is called a ''free vertex''. The basic concept that the algorithm relies on is that of an ''augmenting path'', a path that starts at a free vertex, ends at a free vertex, and alternates between unmatched and matched edges within the path. Augmented path can have only two vertices (both free) and single unmatched edge between them. Note that except for the endpoints, all other vertices (if any) in augmented path must be non-free vertices. If is a matching, and is an augmenting path relative to , then the symmetric difference of the two sets of edges, , would form a matching with size . Thus, by finding augmenting paths, an algorithm may increase the size of the matching. Conversely, suppose that a matching is not optimal, and let be the symmetric difference where is an optimal matching. Then must form a collection of disjoint augmenting paths and cycles or paths in which matched and unmatched edges are of equal number; the difference in size between and is the number of augmenting paths in . Thus, if no augmenting path can be found, an algorithm may safely terminate, since in this case must be optimal. An augmenting path in a matching problem is closely related to the augmenting paths arising in maximum flow problems, paths along which one may increase the amount of flow between the terminals of the flow. It is possible to transform the bipartite matching problem into a maximum flow instance, such that the alternating paths of the matching problem become augmenting paths of the flow problem.〔, section 12.3, bipartite cardinality matching problem, pp. 469–470.〕 In fact, a generalization of the technique used in Hopcroft–Karp algorithm to arbitrary flow networks is known as Dinic's algorithm. : Input: Bipartite graph : Output: Matching : : repeat :: ''maximal set of vertex-disjoint shortest augmenting paths'' :: : until 抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)』 ■ウィキペディアで「Hopcroft–Karp algorithm」の詳細全文を読む スポンサード リンク
|